from django.db import models

# Create your models here.
class BookInfo(models.Model):
    name = models.CharField(max_length=10, verbose_name='书名')
    pub_date = models.DateField(null=False, verbose_name='发布日期')
    readcount = models.IntegerField(default=0, verbose_name='阅读量')
    commentcount = models.IntegerField(default=0, verbose_name='评论量')
    #逻辑删除
    is_delete = models.BooleanField(default=False, verbose_name='逻辑删除')

    class Meta:
        db_table = 'bookinfo'
    def __str__(self):
        return self.name

class PeopleInfo(models.Model):
    SEX = ((0, '男'),
           (1, '女'))

    name = models.CharField(max_length=10, verbose_name='姓名')
    gender = models.SmallIntegerField(choices=SEX, default=0, verbose_name='性别')
    book = models.ForeignKey(BookInfo, on_delete=models.CASCADE, verbose_name='外键')
    description = models.CharField(max_length=200, null=True, verbose_name='武功')
    is_delete = models.BooleanField(default=False, verbose_name='逻辑删除')

    class Meta:
        db_table = 'peopleinfo'

    def __str__(self):
        return self.name






